package com.daigoudao.web.model;

import java.math.BigDecimal;

import com.daigoudao.config.ConfigManager;

/**
 * 订单详情信息
 * 
 * @author zheng
 * 
 */
public class OrderDetailModel {

	/**
	 * 订单ID
	 */
	private int orderId;

	/**
	 * 商品ID
	 */
	private int productId;

	/**
	 * 商品名称
	 */
	private String goodsName;

	/**
	 * 价格
	 */
	private double price;

	/**
	 * 商品图片，相对路径
	 */
	private String image;

	/**
	 * 服务费
	 */
	private double serviceFee;

	/**
	 * 商品数量
	 */
	private int number;

	public int getOrderId() {
		return orderId;
	}

	public void setOrderId(int orderId) {
		this.orderId = orderId;
	}

	public int getProductId() {
		return productId;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}

	public String getGoodsName() {
		return goodsName;
	}

	public void setGoodsName(String goodsName) {
		this.goodsName = goodsName;
	}

	public double getPrice() {
		return BigDecimal.valueOf(price).setScale(2, BigDecimal.ROUND_HALF_UP)
				.doubleValue();
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public double getServiceFee() {
		return BigDecimal.valueOf(serviceFee)
				.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
	}

	public void setServiceFee(double serviceFee) {
		this.serviceFee = serviceFee;
	}

	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
	}

	public String getAbsoluteImage() {
		if (image != null) {
			return ConfigManager.getConfigString("upload.resUrl") + image;
		}
		// TODO 返回默认图片
		return image;
	}

	/**
	 * 小计
	 * 
	 * @return
	 */
	public double getSubTotal() {
		return BigDecimal.valueOf((price + serviceFee) * number)
				.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
	}
}
